package yxy.game.pm2.module.camptower;

import yxy.game.pm2.bean.Constant;
import yxy.game.pm2.bean.PlayerBean;
import yxy.game.pm2.bean.area.AreaBean;
import yxy.game.pm2.bean.module.AreaModule;
import yxy.game.pm2.bean.module.rank.PlayerRankModule;

import java.util.Collection;

/**
 * @ClassName RankQunCampTower
 * @Author jingtao-zheng
 * @Date 2022/8/8 14:09
 * @Version 1.0
 **/
public class RankQunCampTower extends PlayerRankModule {

    public RankQunCampTower(AreaBean areaBean) {
        super(areaBean);
    }

    @Override
    public String rankName() {
        return PlayerRankModule.getAllRankNames().get(21);
    }

    @Override
    protected long valuePlastic(long value) {
        return value * 100;
    }

    @Override
    protected long valueRestore(long score) {
        return score / 100;
    }

    static public void reset() {
        redis().client().getKeys().deleteByPattern("AREA:*:RANK:QUNGUOTA");

        Collection<PlayerBean> all = PlayerBean.all();

        for (PlayerBean bean : all) {
            String pCode = bean.getCode();
            AreaBean areaBean = AreaModule.area(bean);
            CampTowerModule towerModule = CampTowerModule.get(pCode);
            if (towerModule.getFloor().get(Constant.QUN) > 0) {
                new RankShuCampTower(areaBean).put(pCode, towerModule.getFloor().get(Constant.QUN));
            }
        }
    }

    static public RankQunCampTower getRank(String playerCode) {
        AreaBean areaBean = AreaModule.area(playerCode);
        return new RankQunCampTower(areaBean);
    }
}
